package com_bussiness; //页面业务的封装import org.openqa.selenium.By;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import com_page.cla1; //导入页面元素操作的包

public class business {
    private final WebDriver driver;

    /**
     * 构造方法   给driver赋值
     */
    public business(WebDriver driver) {
        this.driver = driver;
    }

    /**
     * 打开URL页面业务       参数是 URL网址
     */
    public void open(String URL) throws Exception {//打开URL页面业务
        //String url="http://localhost:8080/shop1";
        this.driver.get(URL);
    }


    /*添加支付方式*/
    public void Addpay(String value) throws Exception {

        cla1 obj=new cla1();

        //登陆后台
        obj.CLEAR(driver, By.name("a_name"));
        obj.SENDKEY(driver,By.name("a_name"),"admin");
        Thread.sleep(1000);
        obj.CLEAR(driver,By.name("a_pass"));
        obj.SENDKEY(driver,By.name("a_pass"),"admin");

        Thread.sleep(1000);
        obj.CLICK(driver,By.name("submit2"));
        Thread.sleep(1000);


        obj.SWITCH_to_FRAME(driver,By.xpath("/html/body/center[2]/table/tbody/tr[2]/td/table/tbody/tr/td/iframe"));
        obj.SWITCH_to_FRAME(driver,By.name("Left"));
        obj.CLICK(driver,By.linkText("添加支付方式"));

        obj.SWITCH_to_parentFRAME(driver);

        obj.SWITCH_to_FRAME(driver,By.name("Rigth"));
        obj.SENDKEY(driver,By.name("fangshi_name"),value );
        obj.CLICK(driver,By.xpath("/html/body/center/form/table/tbody/tr[4]/td/input"));
    }

    public void queryKey(String value) throws Exception {
        cla1 obj=new cla1();
        Thread.sleep(5000L);
        obj.SENDKEY(driver,By.id("kw"),value);

        Thread.sleep(5000L);

        obj.CLICK(driver,By.id("su"));

        Thread.sleep(5000L);
    }
}